home *** CD-ROM | disk | FTP | other *** search
- unit Main2;
-
- interface
-
- uses
- SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
- Forms, Dialogs, StdCtrls, Grids, Outline, ExtCtrls, TabNotBk,
- MXMAILX;
-
- {$I mailxdef.int}
-
- type
- TDemoForm = class(TForm)
- Tab: TTabbedNotebook;
- Panel1: TPanel;
- Panel2: TPanel;
- Outline1: TOutline;
- btnScan: TButton;
- btnRecipient: TButton;
- btnFiles: TButton;
- btnMessage: TButton;
- Label1: TLabel;
- Label2: TLabel;
- Label3: TLabel;
- Label4: TLabel;
- Label5: TLabel;
- szNotePart: TMemo;
- szSubject: TEdit;
- szFrom: TEdit;
- szTime: TEdit;
- btnReply: TButton;
- btnForward: TButton;
- btnSend: TButton;
- FileGrid: TStringGrid;
- Label6: TLabel;
- Label7: TLabel;
- ReciGrid: TStringGrid;
- szResolve: TEdit;
- BtnResolve: TButton;
- BtnAdd: TButton;
- btnAddress: TButton;
- btnSignOn: TButton;
- szCount: TLabel;
- szStatus: TLabel;
- MXForm1: TMXForm;
- MXSession1: TMXSession;
- MXMessage1: TMXMessage;
- MXMessage2: TMXMessage;
- MXRecipient1: TMXRecipient;
- MXFile1: TMXFile;
- procedure btnSignOnClick(Sender: TObject);
- function IsActiveSession:Boolean;
- procedure RefreshContainer;
- procedure Outline1DblClick(Sender: TObject);
- procedure btnScanClick(Sender: TObject);
- procedure btnMessageClick(Sender: TObject);
- procedure btnRecipientClick(Sender: TObject);
- procedure btnFilesClick(Sender: TObject);
- procedure FormCreate(Sender: TObject);
- procedure RefreshReciGrid;
- procedure BtnResolveClick(Sender: TObject);
- procedure BtnAddClick(Sender: TObject);
- procedure btnAddressClick(Sender: TObject);
- procedure ReciGridDblClick(Sender: TObject);
- procedure btnReplyClick(Sender: TObject);
- procedure btnForwardClick(Sender: TObject);
- procedure btnSendClick(Sender: TObject);
- procedure ClearInboxList;
- procedure RefreshFileGrid;
- private
- { Private declarations }
- public
- { Public declarations }
- end;
-
- var
- DemoForm: TDemoForm;
-
- implementation
-
- {$R *.DFM}
- uses mailsys4;
-
- procedure TDemoForm.btnSignOnClick(Sender: TObject);
- begin
- MXSession1.Logon:=TRUE;
- if IsActiveSession then
- begin
- szStatus.caption:='Active Session Available';
- RefreshContainer;
- end
- else
- begin
- szStatus.caption:='NO Active Session Available';
- szCount.caption:='';
- ClearInboxList;
- end;
- end;
-
- procedure TDemoForm.RefreshContainer;
- var
- PData: PString;
- begin
- szCount.caption:=IntToStr(MXMessage1.MsgCount);
- ClearInboxList;
- Outline1.AddChild(0,'Inbox');
-
- MXMessage1.Action:= ACTION_FINDFIRST;
- While MXMessage1.FetchMsg <> 0 Do
- begin
- PData:=NewStr(MXMessage1.MsgID);
- Outline1.AddChildObject(1,MXMessage1.Subject,PData);
- MXMessage1.Action:= ACTION_FINDNEXT;
- end;
- Tab.PageIndex:=0;
- end;
-
- procedure TDemoForm.ClearInboxList;
- var
- PData: PString;
- Index: Integer;
- begin
- Outline1.BeginUpdate;
- for Index:=2 to Outline1.ItemCount do
- begin
- PData:=Outline1.Items[Index].Data;
- if PData<> nil then
- begin
- DisposeStr(PData);
- end;
- end;
- Outline1.Clear;
- Outline1.EndUpdate;
- end;
-
- function TDemoForm.IsActiveSession:Boolean;
- begin
- if MXSession1.Logon=true then Result:=true
- else
- begin
- Result:=false;
- Application.MessageBox('No Active Session available',
- 'Mail eXtension DEMO for DELPHI',
- MB_ICONSTOP);
- end;
- end;
-
- procedure TDemoForm.Outline1DblClick(Sender: TObject);
- var
- x: PString;
- y:string;
- Index: Integer;
- begin
- if Outline1.SelectedItem>1 then
- begin
- x:=Outline1.Items[Outline1.SelectedItem].Data;
- MXMessage2.MsgID:=x^;
- szSubject.text:=MXMessage2.Subject;
- szNotePart.Lines:=MXMessage2.NoteText;
- szTime.Text:=MXMessage2.TimeReceived;
-
- MXRecipient1.FetchType:=ftORIGINATOR;
- MXRecipient1.FetchRecipient:=TRUE;
- szFrom.Text:=MXRecipient1.RecipientName;
-
- MXRecipient1.FetchType:=ftRECIPIENTS;
- MXRecipient1.FetchRecipient:=TRUE;
- RefreshReciGrid;
- MXFile1.FetchFile:=TRUE;
- RefreshFileGrid;
- Tab.PageIndex:=3;
- end;
- end;
-
- procedure TDemoForm.RefreshFileGrid;
- var
- Index: integer;
- begin
- FileGrid.RowCount:=MXFile1.FileCount;
-
- for Index:=0 to MXFile1.FileCount-1 do
- begin
- MXFile1.FileNum:=Index+1;
- FileGrid.Cells[0,Index]:=MXFile1.FileName;
- FileGrid.Cells[1,Index]:=MXFile1.FilePath;
- end;
- end;
-
- procedure TDemoForm.RefreshReciGrid;
- var
- Index: integer;
- begin
- ReciGrid.RowCount:=MXRecipient1.RecipientCount;
-
- for Index:=0 to MXRecipient1.RecipientCount-1 do
- begin
- MXRecipient1.RecipientNum:=Index+1;
- ReciGrid.Cells[0,Index]:=MXRecipient1.RecipientName;
- ReciGrid.Cells[1,Index]:=MXRecipient1.RecipientAddress;
- end;
- end;
-
- procedure TDemoForm.btnScanClick(Sender: TObject);
- begin
- if IsActiveSession then RefreshContainer;
- end;
-
- procedure TDemoForm.btnMessageClick(Sender: TObject);
- begin
- Tab.PageIndex:=3;
- end;
-
- procedure TDemoForm.btnRecipientClick(Sender: TObject);
- begin
- Tab.PageIndex:=1;
- end;
-
- procedure TDemoForm.btnFilesClick(Sender: TObject);
- begin
- Tab.PageIndex:=2;
- end;
-
- procedure TDemoForm.FormCreate(Sender: TObject);
- var
- MailSystem: TMailSystem;
- begin
- MailSystem:=TMailSystem.Create(Self);
- MailSystem.ShowModal;
- MailSystem.free;
- ReciGrid.ColWidths[0]:=100;
- ReciGrid.ColWidths[1]:=200;
- ReciGrid.RowCount:=0;
- end;
-
- procedure TDemoForm.BtnResolveClick(Sender: TObject);
- begin
- if IsActiveSession then
- begin
- MXRecipient1.ResolveName:=szResolve.Text;
- szResolve.Text:=MXRecipient1.ResolveName;
- end;
- end;
-
- procedure TDemoForm.BtnAddClick(Sender: TObject);
- begin
- if IsActiveSession then
- begin
- MXRecipient1.Action:=ACTION_ADDRECIPIENT;
- RefreshReciGrid;
- end;
- end;
-
- procedure TDemoForm.btnAddressClick(Sender: TObject);
- begin
- if IsActiveSession then
- begin
- MXRecipient1.Action:=ACTION_ADDRESS;
- RefreshReciGrid;
- end;
- end;
-
- procedure TDemoForm.ReciGridDblClick(Sender: TObject);
- var
- rect: TGridRect;
- begin
- if IsActiveSession then
- begin
- rect:=ReciGrid.Selection;
- MXRecipient1.RecipientNum:=rect.top+1;
- MXRecipient1.Action:=ACTION_DETAILS;
- end;
- end;
-
- procedure TDemoForm.btnReplyClick(Sender: TObject);
- begin
- if IsActiveSession then
- begin
- MXMessage2.Action:= ACTION_REPLY;
- MXMessage2.Action:= ACTION_SENDMSG;
- If MXMessage2.ErrorNum <> 0 Then
- begin
- Application.MessageBox ('Unable to Send Message',
- 'Mail eXtension v1.51',
- MB_ICONSTOP);
- end;
- end;
- end;
-
- procedure TDemoForm.btnForwardClick(Sender: TObject);
- begin
- if IsActiveSession then
- begin
- MXMessage2.Action:= ACTION_FORWARD;
- MXMessage2.Action:= ACTION_SENDMSG;
- If MXMessage2.ErrorNum <> 0 Then
- begin
- Application.MessageBox ('Unable to Send Message',
- 'Mail eXtension v1.51',
- MB_ICONSTOP);
- end;
- end;
-
- end;
-
- procedure TDemoForm.btnSendClick(Sender: TObject);
- begin
- if IsActiveSession then
- begin
- MXMessage2.Action:= ACTION_NEW;
- MXMessage2.Action:= ACTION_SENDMSG;
- If MXMessage2.ErrorNum <> 0 Then
- begin
- Application.MessageBox ('Unable to Send Message',
- 'Mail eXtension v1.51',
- MB_ICONSTOP);
- end;
- end;
- end;
-
- end.
-